home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 April: Mac OS SDK / Dev.CD Apr 97 SDK1.toast / Development Kits (Disc 1) / Communications Toolbox / CTB Sample Code 1.0b16 / CTB Sources / Sources 2 / File Transfer Tool for CTB / fset.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-10-06  |  3.1 KB  |  142 lines  |  [TEXT/MPS ]

  1. /************************************************************************************
  2. *
  3. *  Project Name:    Templates
  4. *     File Name:    fset.c
  5. *        Author:    Rob Neville (IIx)
  6. *          Date:    May 18, 1989
  7. *
  8. *   Description:    Template fset function.    
  9. *
  10. *************************************************************************************
  11. *
  12. *    Revision History:
  13. *        5/18/89 - Original version by Rob Neville (IIx)
  14. *        6/26/89 - rev'd for b2 of Toolbox
  15. *
  16. ************************************************************************************/
  17.  
  18. #include "FTTool.h"
  19.  
  20. pascal long FSET(pSetup,msg,p1,p2,p3)
  21. FTSetupPtr    pSetup;
  22. short        msg;
  23. long        p1,p2,p3;
  24. {
  25.     long    theErr = noErr;
  26.     long    ToolDoPreflight();
  27.     long    ToolDoFilter();
  28.     void    ToolDoItem();
  29.     void    ToolDoSetup();
  30.     void    ToolDoCleanup();
  31.     
  32.     switch (msg)
  33.     {
  34.         case XpreflightMsg:
  35.             theErr = ToolDoPreflight(pSetup);
  36.             break;
  37.         case XsetupMsg:
  38.             ToolDoSetup(pSetup);
  39.             break;
  40.         case XitemMsg:
  41.             ToolDoItem(pSetup,p1);
  42.             break;
  43.         case XfilterMsg:
  44.             theErr = ToolDoFilter(pSetup,p1,p2);
  45.             break;
  46.         case XcleanupMsg:
  47.             ToolDoCleanup(pSetup);
  48.             break;
  49.     }
  50.     return (theErr);
  51.     #pragma unused (p3)
  52. }
  53.  
  54.  
  55. void ToolDoSetup(pSetup)
  56. FTSetupPtr    pSetup;
  57. {
  58.     DialogPtr    theDialog;
  59.     ConfigPtr    pConfig;
  60.     short        theKind;
  61.     Handle        theHandle;
  62.     Rect        theRect;
  63.     short        count;
  64.     
  65.     pConfig = (ConfigPtr)pSetup->theConfig;
  66.     theDialog = pSetup->theDialog;
  67.     count = pSetup->count - 1;
  68.     
  69.     GetDItem(theDialog,count + ByronItem,&theKind,&theHandle,&theRect);
  70.     SetCtlValue( (ControlHandle)theHandle,pConfig->param1 ? 1 : 0);
  71.     GetDItem(theDialog,count + RobItem,&theKind,&theHandle,&theRect);
  72.     SetCtlValue((ControlHandle)theHandle,pConfig->param2 ? 1 : 0);
  73. }
  74.  
  75. void ToolDoItem(setupP, itemPtr)
  76. FTSetupPtr     setupP;
  77. short        *itemPtr;
  78. {
  79.      short             theItem;
  80.     short            theKind;
  81.     Handle            theHandle;
  82.     Rect            theRect;
  83.     ConfigPtr         pConfig;
  84.     DialogPtr        theDialog;
  85.     long            first;
  86.     short            theValue;
  87.     
  88.     pConfig = (ConfigPtr)setupP->theConfig;
  89.     theDialog = setupP->theDialog;
  90.     first = setupP->count - 1;
  91.      theItem = *itemPtr;
  92.     GetDItem(theDialog, theItem, &theKind, &theHandle, &theRect);
  93.     theItem = *itemPtr - first;
  94.     switch (theItem) 
  95.     {
  96.         case ByronItem:
  97.             theValue = GetCtlValue((ControlHandle)theHandle);
  98.             SetCtlValue((ControlHandle)theHandle,theValue ^ 1);
  99.             pConfig->param1 = theValue ^ 1;
  100.             break;
  101.         case RobItem:
  102.             theValue = GetCtlValue((ControlHandle)theHandle);
  103.             SetCtlValue((ControlHandle)theHandle, theValue ^ 1);
  104.             pConfig->param2 = theValue ^ 1;
  105.             break;
  106.         default:
  107.             break;
  108.     }
  109. }
  110.  
  111. long ToolDoFilter(setupP, theEvent, itemPtr)
  112. FTSetupPtr     setupP;
  113. EventRecord    *theEvent;
  114. short        *itemPtr;
  115. {    
  116.     #pragma unused (setupP)
  117.     #pragma unused (theEvent)
  118.     #pragma unused (itemPtr)
  119.     return(0);        /* I don't have any special items just check boxes */
  120. }
  121.  
  122. void ToolDoCleanup(setupP)
  123. FTSetupPtr     setupP;
  124. {
  125. #pragma unused (setupP) /* I don't do anything */
  126. }
  127.  
  128.     
  129. long ToolDoPreflight(setupP)
  130. FTSetupPtr    setupP;
  131. {
  132.     short    id;
  133.     Handle    theHandle;
  134.     
  135.     id = CRMLocalToRealID(classFT,(*setupP).procID,'DITL',1);
  136.     if (id == -1)
  137.         return (nil);
  138.     theHandle = GetResource('DITL',id);
  139.     if (theHandle != nil)
  140.         DetachResource(theHandle);
  141.     return ((long)theHandle);
  142. }